package com.example.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import redis.clients.jedis.Jedis;

@RestController
@RequestMapping("/redis")
public class RedisController {
  
  @Autowired
  private Jedis jedis;
  
  @GetMapping("/add/{key}/{value}")
  public void add(@PathVariable(value = "key") String key, @PathVariable("value") String value) {
    jedis.set(key, value);
  }
  
  @GetMapping("/get/{key}")
  public String get(@PathVariable(value = "key") String key) {
    return jedis.get(key);
  }
}
